## Replication code for: Katsumata, Hiroto and Shunya Noda. 2023. 
## "'Kick Them Out' as a Voting Strategy: Theory and Evidence from Multi-member District Elections." 
## The Journal of Politics, forthcoming.

## Analysis of the survey data from the 2004 General Election in Romania
## Author: Hiroto Katsumata
## Date: May, 2023

## Double check that you have not load tidyverse package yet
detach(package:tidyverse,unload=TRUE)
# You will get an error message but it is okay

## Load packages
library(MASS)
library(Hmisc)
library(tidyverse)

## Initial setting
options(stringsAsFactors = FALSE)

## Load functions
source("functions/kickout_functions.R")

## Read data
rou2 <- read.csv("data/rou2.csv", header = TRUE)


## Estimation ====================

## Main data for the analysis: "rou2"
## See the codebook "kickout_codebook.txt" for details
head(rou2)


## A: Kick out the least preferred party among the top M + 1 parties
## Vote for the second-most preferred party against the most preferred one
##  among the top M + 1 parties
## Treatment: preference for the least preferred party among the viable parties
result_rA <- 
subset(rou2, votecompfirst + votecompsecond == 1) %>%
summary_r(data = ., 
					formula = votecompsecond ~ likecompfirst + 
																				 likecompsecond + 
																				 likecompleast + 
																				 factor(dist),
					cov = FALSE,
					type = "a")

result_rAc <- 
subset(rou2, votecompfirst + votecompsecond == 1) %>%
summary_r(data = ., 
					formula = votecompsecond ~ likecompfirst + 
																				 likecompsecond + 
																				 likecompleast + 
																				 factor(dist) + 
																				 age + gender + I(ethnicity == 1) + university + factor(partyID),
					cov = TRUE,
					type = "a")

## B: Kick out the runner-up
## Vote for the second-most preferred party against the most preferred one
##  among the top M parties excluding the runner-up party
## Treatment: preference for the runner-up
result_rB <- 
subset(rou2, votenotrunupwinfirst + votenotrunupwinsecond == 1) %>%
summary_r(data = ., 
					formula = votenotrunupwinsecond ~ likenotrunupwinfirst + 
																						likenotrunupwinsecond + 
																						likerunup + 
																						factor(dist),
					cov = FALSE,
					type = "a")

result_rBc <- 
subset(rou2, votenotrunupwinfirst + votenotrunupwinsecond == 1) %>%
summary_r(data = ., 
					formula = votenotrunupwinsecond ~ likenotrunupwinfirst + 
																						likenotrunupwinsecond + 
																						likerunup + 
																						factor(dist) + 
																						age + gender + I(ethnicity == 1) + university + factor(partyID),
					cov = TRUE,
					type = "a")

result_rBlow <- 
subset(rou2, votenotrunupwinfirst + votenotrunupwinsecond == 1) %>%
filter(magnitude <= 7) %>%
summary_r(data = ., 
					formula = votenotrunupwinsecond ~ likenotrunupwinfirst + 
																						likenotrunupwinsecond + 
																						likerunup + 
																						factor(dist),
					cov = FALSE,
					type = "a")

result_rBhigh <- 
subset(rou2, votenotrunupwinfirst + votenotrunupwinsecond == 1) %>%
filter(magnitude >= 8) %>%
summary_r(data = ., 
					formula = votenotrunupwinsecond ~ likenotrunupwinfirst + 
																						likenotrunupwinsecond + 
																						likerunup + 
																						factor(dist),
					cov = FALSE,
					type = "a")

## C: Kick out the least preferred party among the top M parties
## Vote for the runner-up party against the top M parties
## Treatment: preference for the least preferred party among the top M parties
result_rC1 <- 
subset(rou2, (votewin == 1 | voterunup == 1)) %>%
summary_r(data = ., 
					formula = voterunup ~ likerunup + 
																likenotrunupwinfirst + 
																likenotrunupwinsecond + 
																likenotrunupwinleast + 
																factor(dist),
					cov = FALSE,
					type = "b")

result_rC1c <- 
subset(rou2, (votewin == 1 | voterunup == 1)) %>%
summary_r(data = ., 
					formula = voterunup ~ likerunup + 
																likenotrunupwinfirst + 
																likenotrunupwinsecond + 
																likenotrunupwinleast + 
																factor(dist) + 
																age + gender + I(ethnicity == 1) + university + factor(partyID),
					cov = TRUE,
					type = "b")

result_rC1low <- 
subset(rou2, (votewin == 1 | voterunup == 1)) %>%
filter(magnitude <= 7) %>%
summary_r(data = ., 
					formula = voterunup ~ likerunup + 
																likenotrunupwinfirst + 
																likenotrunupwinsecond + 
																likenotrunupwinleast + 
																factor(dist),
					cov = FALSE,
					type = "b")

result_rC1high <- 
subset(rou2, (votewin == 1 | voterunup == 1)) %>%
filter(magnitude >= 8) %>%
summary_r(data = ., 
					formula = voterunup ~ likerunup + 
																likenotrunupwinfirst + 
																likenotrunupwinsecond + 
																likenotrunupwinleast + 
																factor(dist),
					cov = FALSE,
					type = "b")

result_rC2 <- 
subset(rou2, votelastwin == 0 & 
						 (votewin == 1 | voterunup == 1)) %>%
summary_r(data = ., 
					formula = voterunup ~ likerunup + 
																likenotrunupwinfirst + 
																likenotrunupwinsecond + 
																likenotrunupwinleast + 
																factor(dist),
					cov = FALSE,
					type = "b")

result_rC2c <- 
subset(rou2, votelastwin == 0 & 
						 (votewin == 1 | voterunup == 1)) %>%
summary_r(data = ., 
					formula = voterunup ~ likerunup + 
																likenotrunupwinfirst + 
																likenotrunupwinsecond + 
																likenotrunupwinleast + 
																factor(dist) + 
																age + gender + I(ethnicity == 1) + university + factor(partyID),
					cov = TRUE,
					type = "b")


## Visualize the average marginal effects
## A: Kick out the least preferred party among the top M + 1 parties
## Figure C.2
xlabel <- "Preference for the least preferred viable party"
ylabel <- "Prob. of voting for the second-most preferred viable party        \nvs. most preferred viable party"
subset(rou2, votecompfirst + votecompsecond == 1)$likecompleast %>%
summary()
dist_include <- subset(rou2, votecompfirst + votecompsecond == 1) %>%
								group_by(dist) %>%
								summarise(ymean = mean(votecompsecond)) %>%
								ungroup() %>%
								filter(ymean > 0 & ymean < 1) %>%
								select(dist) %>%
								c()
set.seed(20201234)
res <- glm(votecompsecond ~ likecompleast + 
																likecompfirst + 
																likecompsecond + 
																factor(dist), 
					 family = binomial(probit), x = TRUE, 
					 data = subset(rou2, dist %in% dist_include$dist &
					 										 votecompfirst + votecompsecond == 1)) %>%
			 ame(object = ., treat = 0:9, B = 10000, 
			 		 xlab = xlabel,
			 		 ylab = ylabel,
			 		 ylab2 = "Number of respondents",
			 		 y2scale = 3,
			 		 histobreaks = seq(-0.5, 9.5, by = 1))
res$figure + scale_x_continuous(breaks = seq(0, 9, 3))
ggsave("figures/romaniaA_ame.pdf", width = 19, height = 19, units = "cm")
q13 <- subset(rou2, votecompfirst + votecompsecond == 1)$likecompleast %>%
			 quantile(., probs = c(0.25, 0.75))
res <- glm(votecompsecond ~ likecompleast + 
																likecompfirst + 
																likecompsecond + 
																factor(dist), 
					 family = binomial(probit), x = TRUE, 
					 data = subset(rou2, dist %in% dist_include$dist &
					 										 votecompfirst + votecompsecond == 1)) %>%
			 amedif(object = ., treat = c(q13[1], q13[2]), B = 10000)
res

## B: Kick out the runner-up
## Figure 6
xlabel <- "Preference for the runner-up party"
ylabel <- "Prob. of voting for the second-most preferred    \n leading party vs. most preferred leading party"
subset(rou2, votenotrunupwinfirst + votenotrunupwinsecond == 1)$likerunup %>%
summary()
set.seed(20201234)
res <- glm(votenotrunupwinsecond ~ likerunup + 
																	 likenotrunupwinfirst + 
																	 likenotrunupwinsecond + 
																	 factor(dist), 
					 family = binomial(probit), x = TRUE, 
					 data = subset(rou2, votenotrunupwinfirst + votenotrunupwinsecond == 1)) %>%
			 ame(object = ., treat = 0:10, B = 10000, 
			 		 xlab = xlabel,
			 		 ylab = ylabel,
			 		 ylab2 = "Number of respondents",
			 		 y2scale = 3,
			 		 histobreaks = seq(-0.5, 10.5, by = 1))
res$figure + scale_x_continuous(breaks = c(0, 5, 10))
ggsave("figures/romaniaB_ame.pdf", width = 19, height = 19, units = "cm")
q13 <- subset(rou2, votenotrunupwinfirst + votenotrunupwinsecond == 1)$likerunup %>%
			 quantile(., probs = c(0.25, 0.75))
res <- glm(votenotrunupwinsecond ~ likerunup + 
																	 likenotrunupwinfirst + 
																	 likenotrunupwinsecond + 
																	 factor(dist), 
					 family = binomial(probit), x = TRUE, 
					 data = subset(rou2, votenotrunupwinfirst + votenotrunupwinsecond == 1)) %>%
			 amedif(object = ., treat = c(q13[1:2]), B = 10000)
res

## Comparison to the effect of the preference for the most preferred leading party
set.seed(20201234)
q13_compare <- subset(rou2, votenotrunupwinfirst + votenotrunupwinsecond == 1)$likenotrunupwinfirst %>%
			 quantile(., probs = c(0.25, 0.75))
res <- glm(votenotrunupwinsecond ~ likenotrunupwinfirst + 
																	 likerunup + 
																	 likenotrunupwinsecond + 
																	 factor(dist), 
					 family = binomial(probit), x = TRUE, 
					 data = subset(rou2, votenotrunupwinfirst + votenotrunupwinsecond == 1)) %>%
			 amedif(object = ., treat = c(q13_compare[1:2]), B = 10000)
res

## Comparison to the effect of the preference for the second-most preferred leading party
set.seed(20201234)
q13_compare <- subset(rou2, votenotrunupwinfirst + votenotrunupwinsecond == 1)$likenotrunupwinsecond %>%
			 quantile(., probs = c(0.25, 0.75))
res <- glm(votenotrunupwinsecond ~ likenotrunupwinsecond + 
																	 likerunup + 
																	 likenotrunupwinfirst + 
																	 factor(dist), 
					 family = binomial(probit), x = TRUE, 
					 data = subset(rou2, votenotrunupwinfirst + votenotrunupwinsecond == 1)) %>%
			 amedif(object = ., treat = c(q13_compare[1:2]), B = 10000)
res


## C: Kick out the least preferred party among the top M parties
## Figure 5
xlabel <- "   Preference for the least preferred leading party"
ylabel <- "Prob. of voting for the runner-up vs. the leading parties    "
subset(rou2, (votewin == 1 | voterunup == 1))$likenotrunupwinleast %>%
summary()
dist_include <- subset(rou2, (votewin == 1 | voterunup == 1)) %>%
								filter(is.na(likerunup) == 0 &
											 is.na(likenotrunupwinfirst) == 0 &
											 is.na(likenotrunupwinsecond) == 0 &
											 is.na(likenotrunupwinleast)) %>%
								group_by(dist) %>%
								summarise(ymean = mean(voterunup)) %>%
								ungroup() %>%
								filter(ymean > 0 & ymean < 1) %>%
								select(dist) %>%
								c()
set.seed(20201234)
res <- glm(voterunup ~ likenotrunupwinleast + 
											 likerunup + 
											 likenotrunupwinfirst + 
											 likenotrunupwinsecond + 
											 factor(dist), 
					 family = binomial(probit), x = TRUE, 
					 data = subset(rou2, (votewin == 1 | voterunup == 1))) %>%
			 ame(object = ., treat = 0:9, B = 10000, 
			 		 xlab = xlabel,
			 		 ylab = ylabel,
			 		 ylab2 = "Number of respondents",
			 		 y2scale = 3,
			 		 histobreaks = seq(-0.5, 9.5, by = 1))
res$figure + scale_x_continuous(breaks = seq(0, 9, 3))
ggsave("figures/romaniaC_ame.pdf", width = 19, height = 19, units = "cm")
q13 <- subset(rou2, (votewin == 1 | voterunup == 1))$likenotrunupwinleast %>%
			 quantile(., probs = c(0.25, 0.75))
res <- glm(voterunup ~ likenotrunupwinleast + 
											 likerunup + 
											 likenotrunupwinfirst + 
											 likenotrunupwinsecond + 
											 factor(dist), 
					 family = binomial(probit), x = TRUE, 
					 data = subset(rou2, (votewin == 1 | voterunup == 1))) %>%
			 amedif(object = ., treat = c(q13[1:2]), B = 10000)
res

## Comparison to the effect of the preference for the runner-up party
set.seed(20201234)
q13_compare <- subset(rou2, (votewin == 1 | voterunup == 1))$likerunup %>%
			 quantile(., probs = c(0.25, 0.75))
res <- glm(voterunup ~ likerunup + 
											 likenotrunupwinleast + 
											 likenotrunupwinfirst + 
											 likenotrunupwinsecond + 
											 factor(dist), 
					 family = binomial(probit), x = TRUE, 
					 data = subset(rou2, (votewin == 1 | voterunup == 1))) %>%
			 amedif(object = ., treat = c(q13_compare[1:2]), B = 10000)
res


## LaTeX table
## A: Kick out the least preferred party among the top M + 1 parties
## Table C.2
rnamerA <- c("Pref. for the most preferred",
						 "~~viable party",
						 "Pref. for the second-most preferred",
						 "~~viable party",
						 "Pref. for the least preferred",
						 "~~viable party",
						 "District fixed effects",
						 "Covariates",
						 "Number of observations")

resultrA <- data.frame(rnamerA,
											 NA,
											 result_rA,
											 NA,
											 result_rAc)

clabelsrA <- c("", "", "Model A1", "", "Model A2")
captionrA <- "(Romania CLPR) Kicking out the Least Preferred Viable Party"
noterA <- 
"\\parbox{0.7\\textwidth}
{Notes: Coefficients and standard errors are multiplied by 100. 
The outcome variable is voting for the second-most preferred viable party
against most preferred viable party.
Covariates include respondents' age, gender, education, ethnicity, and party ID.
Standard errors in parentheses.}"

latex(object = resultrA,
      title = "",
      file = "tables/romaniaA.tex",
      label = "tb_romaniaA",
      caption = captionrA,
      insert.bottom = noterA,
      first.hline.double = FALSE,
      rowname = NULL,
      colheads = clabelsrA,
      col.just = c("l", rep("c", ncol(resultrA) - 1)),
      n.rgroup = c(6, 3),
      longtable = FALSE,
      center = "centering")

## B: Kick out the runner-up
## Table D.7
rnamerB <- c("Pref. for the most preferred",
						 "~~leading party",
						 "Pref. for the second-most preferred",
						 "~~leading party",
						 "\\multirow{2}{*}{Pref. for the runner-up party}",
						 "",
						 "District fixed effects",
						 "Covariates",
						 "Number of observations")

resultrB <- data.frame(rnamerB,
											 NA,
											 result_rB,
											 NA,
											 result_rBc)

clabelsrB <- c("", "", "Model B1", "", "Model B2")
captionrB <- "(Romania CLPR) Kicking out the Runner-up Party"
noterB <- 
"\\parbox{0.7\\textwidth}
{Notes: Coefficients and standard errors are multiplied by 100. 
The outcome variable is voting for the second-most preferred leading party
against most preferred leading party.
Covariates include respondents' age, gender, education, ethnicity, and party ID.
Standard errors in parentheses.}"

latex(object = resultrB,
      title = "",
      file = "tables/romaniaB.tex",
      label = "tb_romaniaB",
      caption = captionrB,
      insert.bottom = noterB,
      first.hline.double = FALSE,
      rowname = NULL,
      colheads = clabelsrB,
      col.just = c("l", rep("c", ncol(resultrB) - 1)),
      n.rgroup = c(6, 3),
      longtable = FALSE,
      center = "centering")

## C: Kick out the least preferred party among the top M parties
## Table D.6
rnamerC <- c("\\multirow{2}{*}{Pref. for the runner-up party}",
						 "",
						 "Pref. for the most preferred",
						 "~~leading party",
						 "Pref. for the second-most preferred",
						 "~~leading party",
						 "Pref. for the least preferred",
						 "~~leading party",
						 "District fixed effects",
						 "Covariates",
						 "Number of observations")

resultrC <- data.frame(rnamerC,
											 NA,
											 result_rC1,
											 NA,
											 result_rC1c,
											 NA,
											 result_rC2,
											 NA,
											 result_rC2c)

clabelsrC <- c("", "", "Model C1", "", "Model C2", "", "Model C3", "", "Model C4")
captionrC <- "(Romania CLPR) Kicking out the Least Preferred Leading Party"
noterC <- 
"\\parbox{0.98\\textwidth}
{Notes: Coefficients and standard errors are multiplied by 100. 
The outcome variable is voting for the runner-up
against one of the leading parties.
The samples for Models C3 and C4 exclude voters who vote for the $M$th-place party.
Covariates include respondents' age, gender, education, ethnicity, and party ID.
Standard errors in parentheses.}"

latex(object = resultrC,
      title = "",
      file = "tables/romaniaC.tex",
      label = "tb_romaniaC",
      caption = captionrC,
      insert.bottom = noterC,
      first.hline.double = FALSE,
      rowname = NULL,
      colheads = clabelsrC,
      col.just = c("l", rep("c", ncol(resultrC) - 1)),
      n.rgroup = c(8, 3),
      longtable = FALSE,
      center = "centering")

## Sample splitted by the district magnitude (4--7 and 8--12)
## B: Kick out the runner-up
## Table D.9
rnamerB <- c("District magnitude", 
						 "\\multirow{2}{*}{Preference for the most preferred leading party}",
						 "",
						 "\\multirow{2}{*}{Preference for the second-most preferred leading party}",
						 "",
						 "\\multirow{2}{*}{Preference for the runner-up party}",
						 "",
						 "District fixed effects",
						 "Number of observations")

resultrB <- data.frame(rnamerB,
											 NA,
											 c("$M \\leq 7$", result_rBlow[-8]),
											 NA,
											 c("$M \\geq 8$", result_rBhigh[-8]))

clabelsrB <- c("", "", "Low", "", "High")
captionrB <- "(Romania CLPR) Kicking out the Runner-up Party in Low and High Magnitude Districts"
noterB <- 
"\\parbox{0.88\\textwidth}
{Notes: Coefficients and standard errors are multiplied by 100. 
The outcome variable is voting for the second-most preferred leading party
against most preferred leading party.
Standard errors in parentheses.}"

latex(object = resultrB,
      title = "",
      file = "tables/romaniaBdm.tex",
      label = "tb_romaniaBdm",
      caption = captionrB,
      insert.bottom = noterB,
      first.hline.double = FALSE,
      rowname = NULL,
      colheads = clabelsrB,
      col.just = c("l", rep("c", ncol(resultrB) - 1)),
      n.rgroup = c(1, 6, 2),
      longtable = FALSE,
      center = "centering")

## C: Kick out the least preferred party among the top M parties
## Table D.8
rnamerC <- c("District magnitude", 
						 "\\multirow{2}{*}{Preference for the runner-up party}",
						 "",
						 "\\multirow{2}{*}{Preference for the most preferred leading party}",
						 "",
						 "\\multirow{2}{*}{Preference for the second-most preferred leading party}",
						 "",
						 "\\multirow{2}{*}{Preference for the least preferred leading party}",
						 "",
						 "District fixed effects",
						 "Number of observations")

resultrC <- data.frame(rnamerC,
											 NA,
											 c("$M \\leq 7$", result_rC1low[-10]),
											 NA,
											 c("$M \\geq 8$", result_rC1high[-10]))

clabelsrC <- c("", "", "Low", "", "High")
captionrC <- "(Romania CLPR) Kicking out the Least Preferred Leading Party in Low and High Magnitude Districts"
noterC <- 
"\\parbox{0.88\\textwidth}
{Notes: Coefficients and standard errors are multiplied by 100. 
The outcome variable is voting for the runner-up
against one of the leading parties.
Standard errors in parentheses.}"

latex(object = resultrC,
      title = "",
      file = "tables/romaniaCdm.tex",
      label = "tb_romaniaCdm",
      caption = captionrC,
      insert.bottom = noterC,
      first.hline.double = FALSE,
      rowname = NULL,
      colheads = clabelsrC,
      col.just = c("l", rep("c", ncol(resultrC) - 1)),
      n.rgroup = c(1, 8, 2),
      longtable = FALSE,
      center = "centering")


## Estimation of the proportions of semi-sincere and kick-out voters
## Number of viable parties = 3
propK3 <- rou2 %>% 
filter(n_comp == 3) %>%
summarise(ko_ub1 = mean(likerunup == likecompthird & votelastwin == 1),
					ko_lb1 = mean(likerunup == likecompthird & votelastwin == 1 & 
												votecompfirst == 0),
					ko_ub2 = mean(likerunup != likecompthird & voterunup == 1),
					ko_lb2 = mean(likerunup != likecompthird & voterunup == 1 & 
												votecompfirst == 0),
					ss_ub = mean(votecompfirst == 1),
					koss1 = mean(likerunup == likecompthird & votelastwin == 1 & 
												votecompfirst == 1),
					koss2 = mean(likerunup != likecompthird & voterunup == 1 & 
												votecompfirst == 1)) %>%
mutate(ko_ub = ko_ub1 + ko_ub2,
			 ko_lb = ko_lb1 + ko_lb2,
			 koss = koss1 + koss2,
			 ss_lb = ss_ub - koss,
			 propD = 1 - koss - ko_lb - ss_lb,
			 propBD = 1 - ss_ub,
			 propCD = 1 - ko_ub,
			 prop_cross_pressured = ko_lb / (ko_lb + ss_lb))
propK3 <- format(round(propK3 * 100, 1), nsmall = 1)
propA <- paste0(propK3$koss, "\\%")
propB <- paste0(propK3$ko_lb, "\\%")
propC <- paste0(propK3$ss_lb, "\\%")
propD <- paste0(propK3$propD, "\\%")
propAB <- paste0(propK3$ko_ub, "\\%")
propAC <- paste0(propK3$ss_ub, "\\%")
propBD <- paste0(propK3$propBD, "\\%")
propCD <- paste0(propK3$propCD, "\\%")
propABCD <- paste0("100.0\\%")

## Table D.4
rnameP_K3 <- c("", 
	             "",
	             "\\multirow{2}{*}{Kick-out Voting}",
						   "",
						   "Total")
resultP_K3 <- data.frame(rnameP_K3,
	                    c("", "", "Yes", "No", ""),
											NA,
											c("\\multicolumn{2}{c}{Semi-sincere Voting}", "Yes", propA, propC, propAC),
											NA,
											c("", "No", propB, propD, propBD),
											NA,
											c("\\multirow{2}{*}{Total}", "", propAB, propCD, propABCD))
captionP_K3 <- "(Romania CLPR; three viable parties) Proportions of the Kick-out and Semi-sincere Voters"
latex(object = resultP_K3,
      title = "",
      file = "tables/roumaniaP_K3.tex",
      label = "tb_roumaniaP_K3",
      caption = captionP_K3,
      first.hline.double = FALSE,
      colheads = FALSE,
      rowname = NULL,
      col.just = c("l", rep("c", ncol(resultP_K3) - 1)),
      longtable = FALSE,
      center = "centering")

## Number of viable parties = 4
propK4 <- rou2 %>% 
filter(n_comp == 4) %>%
summarise(ko_ub1 = mean(likerunup == likecompfourth & votelastwin == 1),
					ko_lb1 = mean(likerunup == likecompfourth & votelastwin == 1 & 
												votecompfirst == 0),
					ko_ub2 = mean(likerunup != likecompfourth & voterunup == 1),
					ko_lb2 = mean(likerunup != likecompfourth & voterunup == 1 & 
												votecompfirst == 0),
					ss_ub = mean(votecompfirst == 1),
					koss1 = mean(likerunup == likecompfourth & votelastwin == 1 & 
												votecompfirst == 1),
					koss2 = mean(likerunup != likecompfourth & voterunup == 1 & 
												votecompfirst == 1)) %>%
mutate(ko_ub = ko_ub1 + ko_ub2,
			 ko_lb = ko_lb1 + ko_lb2,
			 koss = koss1 + koss2,
			 ss_lb = ss_ub - koss,
			 propD = 1 - koss - ko_lb - ss_lb,
			 propBD = 1 - ss_ub,
			 propCD = 1 - ko_ub,
			 prop_cross_pressured = ko_lb / (ko_lb + ss_lb))
propK4 <- format(round(propK4 * 100, 1), nsmall = 1)
propA <- paste0(propK4$koss, "\\%")
propB <- paste0(propK4$ko_lb, "\\%")
propC <- paste0(propK4$ss_lb, "\\%")
propD <- paste0(propK4$propD, "\\%")
propAB <- paste0(propK4$ko_ub, "\\%")
propAC <- paste0(propK4$ss_ub, "\\%")
propBD <- paste0(propK4$propBD, "\\%")
propCD <- paste0(propK4$propCD, "\\%")
propABCD <- paste0("100.0\\%")

## Table D.5
rnameP_K4 <- c("", 
	             "",
	             "\\multirow{2}{*}{Kick-out Voting}",
						   "",
						   "Total")
resultP_K4 <- data.frame(rnameP_K4,
	                    c("", "", "Yes", "No", ""),
											NA,
											c("\\multicolumn{2}{c}{Semi-sincere Voting}", "Yes", propA, propC, propAC),
											NA,
											c("", "No", propB, propD, propBD),
											NA,
											c("\\multirow{2}{*}{Total}", "", propAB, propCD, propABCD))
captionP_K4 <- "(Romania CLPR; four viable parties) Proportions of the Kick-out and Semi-sincere Voters"
latex(object = resultP_K4,
      title = "",
      file = "tables/roumaniaP_K4.tex",
      label = "tb_roumaniaP_K4",
      caption = captionP_K4,
      first.hline.double = FALSE,
      colheads = FALSE,
      rowname = NULL,
      col.just = c("l", rep("c", ncol(resultP_K4) - 1)),
      longtable = FALSE,
      center = "centering")
